//
// Copyright (c) 2009 All Right Reserved
//
// Stephen Toub
// stoub@microsoft.com
// 2009-01-01
// Contains ...
using System;
using System.IO;
using System.Text;
namespace LargoCommon.Midi {
/// A proprietary meta event message.
[Serializable]
public sealed class MetaProprietary : MetaEvent {
/// The meta id for this event.
private const byte EventMetaId = 0x7F;
#region Fields
///
/// Event data.
///
private byte[] data;
#endregion
#region Constructors
/// Initializes a new instance of the MetaProprietary class.
/// The amount of time before this event.
/// The data associated with the event.
public MetaProprietary(long deltaTime, byte[] givenData) :
base(deltaTime, EventMetaId) {
this.SetData(givenData);
}
#endregion
#region To String
/// Generate a string representation of the event.
/// A string representation of the event.
public override string ToString() {
var sb = new StringBuilder();
sb.Append(base.ToString());
if (this.GetData() != null) {
sb.Append("\t");
}
sb.Append(MidiEvent.DataToString(this.GetData()));
return sb.ToString();
}
#endregion
#region Methods
/// Write the event to the output stream.
/// The stream to which the event should be written.
public override void Write(Stream outputStream) {
//// Contract.Requires(outputStream != null);
if (outputStream == null) {
return;
}
//// Write out the base event information
base.Write(outputStream);
// Event data
var data1 = this.GetData();
MidiEvent.WriteVariableLength(outputStream, data1?.Length ?? 0);
if (data1 != null) {
outputStream.Write(data1, 0, data1.Length);
}
}
#endregion
#region Private data
///
/// Gets or sets the data for the event.
///
/// Returns value.
/// General musical property.
private byte[] GetData() {
return this.data;
}
///
/// Sets the data.
///
/// The value.
private void SetData(byte[] value) {
this.data = value;
}
#endregion
}
}